﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using DCTLib.Common;
using DCSLibrary;

public partial class TimKiem_AdvanceSearch : System.Web.UI.MasterPage
{
    protected string linkLogin = string.Empty;
    protected string linkRegister = string.Empty;  
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadMenu();
        }

        if (Session["User"] == null || string.IsNullOrEmpty(Session["User"].ToString()))
        {
            linkRegister = " <a href=\"/dang-ky-nguoi-dung.aspx\">Đăng ký</a> | ";
            linkLogin = "<a href=\"/dang-nhap-nguoi-dung.aspx\">Đăng nhập</a> | ";            
        }
        else
        {
            linkLogin += "<a href=\"/quan-ly-tai-khoan.aspx\">Quản lý</a> | ";
            linkLogin += "<a href=\"/Default.aspx?user=logout\">[" + Session["User"].ToString() + "] LogOut</a> | ";
        }
        if (Request.QueryString["user"] == "logout")
        {
            Session.Remove("User");
            Session.Clear();
            CookieHelper.RemoveAllCookies();

            linkRegister = " <a href=\"/dang-ky-nguoi-dung.aspx\">Đăng ký</a> | ";
            linkLogin = "<a href=\"/dang-nhap-nguoi-dung.aspx\">Đăng nhập</a> | ";
        }
    }

    private void LoadMenu()
    {
        try
        {
            rptMenu.DataSource = new CategoryPageUI().GetByParent(Convert.ToInt32(ConfigurationManager.AppSettings["NewsID"])).Tables[0];
            rptMenu.DataBind();
        }
        catch (Exception ex)
        {
        }
    }
}
